table.SUMMARIZE Function

IN THIS PAGE

Syntax

V <TBL>.SUMMARIZE()

Description

Summarize the records of the table into a specified output table.

Specify the required values in the Sum dot variable, then use the following command: <TBL>.SUMMARIZE()

sum.db

Type "C". The name of the resulting table.

sum.order

Type "C". A character order expression that sorts selected records.

sum.filter

Type "C". A character filter expression that selects records to process.

sum.options

Type "C". Options used when ordering the Result table records. This string can contain one or more of the following index codes:

Code
Description
D

The Descending Order option puts the records in the Result table in descending alphabetical order or, for a numeric field, from highest to lowest value.

I

Index should be built as case insensitive.

U

The Unique option uses only unique records in the summary.

sum.fields

Type "N". Indicates how many fields are to be summarized. Each field to be included in the Summary operation is declared through a pair of parameters that indicate the field name and summary operator for that field.

sum.field1 ... C sum.fieldN

Type "C". Fields (1 ... N) containing the names of the field(s) to be summarized.

sum.code1 ... N sum.codeN

Type "N". Fields (1 ... N) containing the operation codes for the fields to be summarized. The following codes may be used:

Code
Details
SUM_OP_TOTAL (1)

Operation: Total. Returns: The sum of values for the specified field or expression.

SUM_OP_COUNT (2)

Operation: Count. Returns: A count of the number of records included in the specified field or expression.

SUM_OP_MIN (3)

Operation: Min. Returns: The minimum (smallest) value for the specified field or expression.

SUM_OP_MAX (4)

Operation: Max. Returns: The maximum (largest) value for the specified field or expression.

SUM_OP_AVERAGE (5)

Operation: Average. Returns: The average of values for the specified field or expression..

SUM_OP_FIRST (6)

Operation: First. Returns: The first value for the specified field or expression.

SUM_OP_LAST (7)

Operation: Last. Returns: The last value for the specified field or expression.

NULL (15)

Returns: Adds a column label in the output table for the specified field.

Discussion

The <TBL>.SUMMARIZE() method is a high-level utility used to summarize the records of a specified table, creating a new table to store the result. Most parameters passed to <TBL>.SUMMARIZE()through the summary function variable correspond directly with the prompts appearing on the Summarize Builder which is accessed by defining a new summary operation from the Control Panel.

Example

This script counts the number of customers who live in each state. The result will be put in the specified output table.

output_tbl = ui_get_file("Result Table","Tables(*.DBF)","","N")
if output_tbl = "" then
 end
end if
tbl = table.current()
sum.db = output_tbl
sum.order = "STATE_PROV"
sum.filter = ""
sum.options = "I"
sum.fields = 2
sum.field1 = "STATE_PROV"
sum.code1 = 0
sum.field2 = "LAST_NAME"
sum.code2 = 2
tbl.summarize()

See Also